\doxysection{cr\+QUEUE\+\_\+\+RECEIVE\+\_\+\+FROM\+\_\+\+ISR }
\hypertarget{group__cr_q_u_e_u_e___r_e_c_e_i_v_e___f_r_o_m___i_s_r}{}\label{group__cr_q_u_e_u_e___r_e_c_e_i_v_e___f_r_o_m___i_s_r}\index{crQUEUE\_RECEIVE\_FROM\_ISR@{crQUEUE\_RECEIVE\_FROM\_ISR}}
croutine. h 
\begin{DoxyPre}
 crQUEUE\_SEND\_FROM\_ISR(                            QueueHandle\_t pxQueue,                            void *pvBuffer,                            BaseType\_t * pxCoRoutineWoken                       )\end{DoxyPre}


The macro\textquotesingle{}s cr\+QUEUE\+\_\+\+SEND\+\_\+\+FROM\+\_\+\+ISR() and cr\+QUEUE\+\_\+\+RECEIVE\+\_\+\+FROM\+\_\+\+ISR() are the co-\/routine equivalent to the x\+Queue\+Send\+From\+ISR() and x\+Queue\+Receive\+From\+ISR() functions used by tasks.

cr\+QUEUE\+\_\+\+SEND\+\_\+\+FROM\+\_\+\+ISR() and cr\+QUEUE\+\_\+\+RECEIVE\+\_\+\+FROM\+\_\+\+ISR() can only be used to pass data between a co-\/routine and and ISR, whereas x\+Queue\+Send\+From\+ISR() and x\+Queue\+Receive\+From\+ISR() can only be used to pass data between a task and and ISR.

cr\+QUEUE\+\_\+\+RECEIVE\+\_\+\+FROM\+\_\+\+ISR can only be called from an ISR to receive data from a queue that is being used from within a co-\/routine (a co-\/routine posted to the queue).

See the co-\/routine section of the WEB documentation for information on passing data between tasks and co-\/routines and between ISR\textquotesingle{}s and co-\/routines.


\begin{DoxyParams}{Parameters}
{\em x\+Queue} & The handle to the queue on which the item is to be posted.\\
\hline
{\em pv\+Buffer} & A pointer to a buffer into which the received item will be placed. The size of the items the queue will hold was defined when the queue was created, so this many bytes will be copied from the queue into pv\+Buffer.\\
\hline
{\em px\+Co\+Routine\+Woken} & A co-\/routine may be blocked waiting for space to become available on the queue. If cr\+QUEUE\+\_\+\+RECEIVE\+\_\+\+FROM\+\_\+\+ISR causes such a co-\/routine to unblock \texorpdfstring{$\ast$}{*}px\+Co\+Routine\+Woken will get set to pd\+TRUE, otherwise \texorpdfstring{$\ast$}{*}px\+Co\+Routine\+Woken will remain unchanged.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pd\+TRUE an item was successfully received from the queue, otherwise pd\+FALSE.
\end{DoxyReturn}
Example usage\+: 
\begin{DoxyPre}
// A co-\/routine that posts a character to a queue then blocks for a fixed
// period.  The character is incremented each time.
static void vSendingCoRoutine( CoRoutineHandle\_t xHandle, UBaseType\_t uxIndex )
\{
// cChar holds its value while this co-\/routine is blocked and must therefore
// be declared static.
static char cCharToTx = 'a';
BaseType\_t xResult;

    // All co-\/routines must start with a call to crSTART().
    crSTART( xHandle );

    for( ;; )
    \{
        // Send the next character to the queue.
        crQUEUE\_SEND( xHandle, xCoRoutineQueue, \&cCharToTx, NO\_DELAY, \&xResult );

        if( xResult == pdPASS )
        \{
            // The character was successfully posted to the queue.
        \}
     else
     \{
        // Could not post the character to the queue.
     \}

        // Enable the UART Tx interrupt to cause an interrupt in this
     // hypothetical UART.  The interrupt will obtain the character
     // from the queue and send it.
     ENABLE\_RX\_INTERRUPT();

     // Increment to the next character then block for a fixed period.
     // cCharToTx will maintain its value across the delay as it is
     // declared static.
     cCharToTx++;
     if( cCharToTx > 'x' )
     \{
        cCharToTx = 'a';
     \}
     crDELAY( 100 );
    \}

    // All co-\/routines must end with a call to crEND().
    crEND();
\}

// An ISR that uses a queue to receive characters to send on a UART.
void vUART\_ISR( void )
\{
char cCharToTx;
BaseType\_t xCRWokenByPost = pdFALSE;

    while( UART\_TX\_REG\_EMPTY() )
    \{
        // Are there any characters in the queue waiting to be sent?
     // xCRWokenByPost will automatically be set to pdTRUE if a co-\/routine
     // is woken by the post -\/ ensuring that only a single co-\/routine is
     // woken no matter how many times we go around this loop.
        if( crQUEUE\_RECEIVE\_FROM\_ISR( pxQueue, \&cCharToTx, \&xCRWokenByPost ) )
     \{
         SEND\_CHARACTER( cCharToTx );
     \}
    \}
\}\end{DoxyPre}
 